import { createRouter, createWebHistory } from 'vue-router';
import { staticRoutes } from '@/router/routes';

const router = createRouter({
	history: createWebHistory(),
	routes: staticRoutes,
  scrollBehavior() {
    return { top: 0, left: 0}
  },
})
router.beforeEach((to,from,next)=>{
  const token = localStorage.getItem('token') as string
  if(token){
    //说明登陆了
    if(to.path === '/login'){
      next(false)
    }else{
      next()
    }
  }else{
    next()
  }
})

// 导出路由
export default router;